/**
 * Created by python on 19-3-4.
 */
let vm = new Vue({
    el: '#base_person_info',
    data: {
        host: HOST,
        user_id: localStorage.user_id || sessionStorage.user_id,
        token: localStorage.token || sessionStorage.token,
        nickname: '',
        avatar_url: '',
        personal_url: '',
        company: '',
        school: '',
        city: '',
    },
    mounted: function () {
         this.get_user_info();
    },
    methods: {
        // 获取当前登陆用户信息
        get_user_info: function () {
            axios.get(this.host + '/user/', {
                // 向后端传递JWT token的方法
                        headers: {
                            'Authorization': 'JWT ' + this.token
                        },
                        responseType: 'json',
            })
                .then(response => {
                    // 加载用户数据
                    this.user_id = response.data.id;
                    this.nickname = response.data.nickname;
                    this.avatar_url = response.data.avatar_url;
                    this.personal_url = response.data.personal_url;

                });
            axios.get(this.host + '/resume/'+this.user_id, {
                responseType: 'json',
            })
                .then(response=>{
                    this.company = response.data.company;
                    this.school = response.data.school;
                    this.city = response.data.city;
                })
        }
    }
});